import { ref } from 'vue'
import { VSnackbar } from 'vuetify/components'

interface SnackbarOptions {
  text: string
  color?: string
  timeout?: number
  actions?: Array<{
    text: string
    color?: string
    onClick?: () => void
  }>
}

const snackbarRef = ref<InstanceType<typeof VSnackbar> | null>(null)

export function useSnackbar() {
  const showSnackbar = (options: SnackbarOptions) => {
    if (snackbarRef.value) {
      snackbarRef.value.text = options.text
      snackbarRef.value.color = options.color || 'primary'
      snackbarRef.value.timeout = options.timeout || 3000
      snackbarRef.value.actions = options.actions?.map(action => ({
        text: action.text,
        color: action.color || 'white',
        onClick: action.onClick
      }))
      snackbarRef.value.modelValue = true
    }
  }

  return {
    showSnackbar,
    snackbarRef
  }
} 